home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
Magazine
/
Online
/
httpproxy
/
src
/
service.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-20
|
4KB
|
150 lines
/*(( "Header" */
/*
* $Id: service.c,v 1.4 1996/08/20 17:36:43 mshopf Exp mshopf $
*
* (c) 1995-96 Matthias Hopf
*
* Log file functions for httpproxy.
*
*/
/*
* $Log: service.c,v $
* Revision 1.4 1996/08/20 17:36:43 mshopf
* new queuing mode.
*
* Revision 1.3 1996/08/11 22:25:15 mshopf
* reworked debug messages.
*
* Revision 1.2 1996/06/06 23:01:23 mshopf
* added mode service.
* url logging bug fix.
*
* Revision 1.1 1996/06/03 04:17:23 mshopf
* Initial revision
*
*/
/*)) */
/*(( "Includes" */
#include "httpproxy.h"
#include <string.h>
#define MAX_SERVICELEN 16 /* Maximum service length including trailing 0x00 */
/*)) */
/*(( "ConfigService ()" */
/* scan Object name for configuration commands */
int ConfigService (request_t *Req, const char *Object)
{
switch (Object[1]) {
case 'o': /* online mode */
if (Object[2] == '0' || Object[2] == '1')
{
OffLine = '1' - Object[2];
if (OffLine)
ShutdownConnects (); /* remove working requests */
else
CheckGetQueued (TRUE); /* Force rescan of queued URLs */
ErrToReq (Req, 202, -1, "Configuration: Online state", OffLine ? "HttpProxy is now in offline state." :
(GetQueued ? "HttpProxy is now in online state and getting queued URLs." :
"HttpProxy is now in online state") , Object);
return (2);
}
break;
case 'g': /* getting queued URLs */
if (Object[2] == '0' || Object[2] == '1')
{
GetQueued = Object[2] - '0';
if (! OffLine)
CheckGetQueued (TRUE); /* Force rescan of queued URLs */
ErrToReq (Req, 202, -1, "Configuration: Get queued URLs state", GetQueued ? (OffLine ? "HttpProxy will get queued URLs as soon as it is online." :
"HttpProxy will get queued URLs now.") :
"HttpProxy will not get any queued URLs automatically.", Object);
return (2);
}
break;
default:
break;
}
ErrToReq (Req, 400, 0, "Unknown configuration service", "The requested configuration service is not supported or unknown.", Object);
return (2);
}
/*)) */
/*(( "ModeService ()" */
/* scan Object name for mode commands */
int ModeService (request_t *Req, const char *Object)
{
switch (Object[1]) {
case 'r': /* reload mode */
if (Object[2] == '0' || Object[2] == '1')
{
AlwaysReload = Object[2] - '0';
ErrToReq (Req, 202, -1, "Mode: Reload", AlwaysReload ? "HttpProxy is now in reload mode. No requests will be served from the cache." :
"HttpProxy is now in standard mode.", Object);
return (2);
}
break;
case 'q': /* queue mode */
if (Object[2] == '0' || Object[2] == '1')
{
QueueMode = Object[2] - '0';
ErrToReq (Req, 202, -1, "Mode: Queuing", QueueMode ? "HttpProxy is now in queuing mode. While offline HttpProxy will queue URL requests "
"that are not in the cache." :
"HttpProxy will not queue any expired cache entries now. New followed links will not "
"be queued, too. However, reload requests will still queue the current document.", Object);
return (2);
}
break;
default:
break;
}
ErrToReq (Req, 400, 0, "Unknown mode service", "The requested mode service is not supported or unknown.", Object);
return (2);
}
/*)) */
/*(( "ScanService ()" */
/* The main function: scan Object name for commands */
/* return values: see ScanUrl() in httpproxy.c */
int ScanService (request_t *Req, const char *Object)
{
static char Obj [MAX_SERVICELEN];
debug (D_REQUEST, ("%02d: service '%s'\n", Req-Requests, Object));
strncpy (Obj, Object, MAX_SERVICELEN); /* will be needed for logging afterwards (hacky...) */
Obj [MAX_SERVICELEN-1] = '\0';
switch (Obj[0]) {
case 'c': /* change Configuration */
return (ConfigService (Req, Obj));
case 'm': /* change Mode */
return (ModeService (Req, Obj));
case 'l': /* List objects */
case 'r': /* Remove entry */
case 'v': /* Mark entry as valid */
default:
break;
}
ErrToReq (Req, 400, 0, "Unknown service", "The requested service is not supported or unknown.", Obj);
return (2);
}
/*)) */